import { Button, Modal } from 'antd';
import React, { useState } from 'react';
import Rbiaoge from '../Rbiaoge/Rbiaoge';
import { Input, Space } from 'antd';
import axios from '../../../utils/axios'

const Duihuakuang = (props) => {
  const { Search } = Input;
  const [tabData, setTabData] = useState([]);
  const [visible, setVisible] = useState(false);
  const onSearch = (value) => {
    console.log(value)
    axios({
      url: "/car/carPage/saveCar",
      method: "get",
      params: {
        car_user: value,
        pageSize: 10,
        currentPage: 1,

      }
    }).then((res) => {
      setTabData(res.data);
      console.log(res);
    }).then((err) => {
      console.log(err);
    })
  };
  const getsateall = () => {
    setVisible(true);

    axios({
      url: "/car/carPage/findAllCar",
      method: "get",
      params: {

        currentPage: 1,
        pageSize: 10

      }
    }).then((res) => {
      console.log(res);
    }).then((err) => {
      console.log(err);
    })
  };
  return (
    <>
      <Button type="primary" onClick={getsateall}>
        用车记录
      </Button>
      <Modal
        title="用车记录"
        centered
        visible={visible}
        onOk={() => setVisible(false)}
        onCancel={() => setVisible(false)}
        width={1600}

      >
        <Space direction="vertical">
          <Search placeholder="请输入" onSearch={onSearch} enterButton />
        </Space>
        <Rbiaoge list={tabData}></Rbiaoge>

      </Modal>
    </>
  );
};

export default Duihuakuang;